// pages/components/goods-detail-comment/goods-detail-comment.js
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    replyInfo: {
      type: Object,
      value: {
        sumCount: 0,
        replyChance: 0,
        productReply: {},
      }
    }
  },

  lifetimes: {
    attached: function () {
      // 在组件实例进入页面节点树时执行
      // console.log("JJLog:之类来==：" + this.properties.show)
      // this.setData({
      //   showPop: this.properties.show
      // })
      if (this.properties.replyInfo.productReply.score) {
        let arr = [];
        for (let i = 0; i < this.properties.replyInfo.productReply.score; i++) {
          arr.push(1);
        }
        let len = arr.length;
        if (len < 5) {
          for (let i = len; i < 5; i++) {
            arr.push(0);
          }
        }
        this.setData({
          starArr: arr
        })
      }

    },
    detached: function () {
      // 在组件实例被从页面节点树移除时执行
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    starArr: [],
    commentTags: [{
      title: "有图有视频",
      number: 3
    },
    {
      title: "好评",
      number: 213
    },
    {
      title: "价格实惠",
      number: 213
    },
    {
      title: "下次还来",
      number: 213
    }
    ],

  },

  /**
   * 组件的方法列表
   */
  methods: {
    // 跳转到评价列表
    pushToCommentList() {
      wx.navigateTo({
        url: '/featurePackage/pages/commentList/commentList?productId=' + this.properties.replyInfo.productId,
      })
    },
    previewImgs(e) {
      let url = e.currentTarget.dataset.url;
      let urls = e.currentTarget.dataset.imgs;
      wx.previewImage({
        current: url,
        urls: urls,
      })
    },
  }
})